package com.it2297.renderer;

import java.awt.Color;
import java.awt.Component;
import java.sql.Timestamp;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import com.it2297.main.App;
import com.it2297.model.Bid;
import com.it2297.model.UsedItem;

@SuppressWarnings("serial")
public class DonationHistoryCellRenderer extends JLabel implements TableCellRenderer
{

	private UsedItem usedItem;

	@Override
	public Component getTableCellRendererComponent(JTable table, Object object, boolean isSelected, boolean hasFocus, int row, int column)
	{
		usedItem = (UsedItem) object;

		switch (column)
		{
			case 0:
				this.setIcon(new ImageIcon(System.getProperty("user.dir") + "/img/used-item/" + usedItem.getUuid() + "-0-thumbnail.png"));
				this.setText("<html><body style='text-align:center'><small><strong>" + usedItem.getTitle() + "</strong></small></body></html>");
				break;
			case 1:
				this.setIcon(null);
				this.setText("<html><body style='text-align:center'><small>" + usedItem.getDateCreate() + "</small></html>");
				break;
		}

		if (row % 2 == 0)
		{
			this.setBackground(Color.WHITE);
		}
		else
		{
			this.setBackground(new Color(240, 240, 240));
		}
		this.setForeground(Color.BLACK);

		return this;
	}

}
